/*
 * TCSS 360 - Winter 2014
 * TESK Software
 */
package view;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.JMenuItem;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Provides a Menu bar on top of border layout in frame.
 * @author Kon
 * @version 3/7/14.
 */
@SuppressWarnings("serial")
public class MenuBar extends JMenuBar{
	/** The frame to associate the menu bar with. */
	private MainFrame my_frame;
	
	/**
	 * Constructs the menu bar object.
	 * 
	 * @param the_frame the frame to associate the menu bar with
	 */
	public MenuBar(MainFrame the_frame){
		super();
		my_frame = the_frame;
		menuBar();
	}
	
	/**
	 * Adds features and specifications of the menu bar. 
	 */
	private void menuBar(){
		//JMenuBar menuBar = new JMenuBar();

		JMenu fileMenu = new JMenu("File");
		fileMenu.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		fileMenu.setHorizontalAlignment(SwingConstants.LEFT);
		fileMenu.setMnemonic('F');
		this.add(fileMenu);

		JMenuItem conference = new JMenuItem("Conference List");
		conference.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		fileMenu.add(conference);
		conference.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				JFrame frame = new JFrame();
				CurrentConference current = new CurrentConference(my_frame);
				current.setup();
				frame.add(current);
				frame.setVisible(true);
				frame.setResizable(false);
				frame.pack();
			}
		});

		JMenuItem roleItem = new JMenuItem("Role Info");
		roleItem.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		fileMenu.add(roleItem);
		roleItem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null,"Conference roles and responsibilities: " +
						"http://www.ieee.org/conferences_events/conferences/organizers/roles_responsibilities.html");
				//just a panel of role and responsibilities.
				//http://www.ieee.org/conferences_events/conferences/organizers/roles_responsibilities.html
			}
		});

		JMenuItem exit = new JMenuItem("Exit");
		exit.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		fileMenu.add(exit);

		exit.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				System.exit(0);
			}
		});
		

		JMenu helpMenu = new JMenu("Help");
		helpMenu.setMnemonic('H');
		helpMenu.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		this.add(helpMenu);

		JMenuItem aboutItem = new JMenuItem("About...");
		helpMenu.add(aboutItem);
		aboutItem.setFont(new Font("Segoe UI", Font.PLAIN, 14));

		aboutItem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				//maybe a message dialog say something about this program or tesk team.
				JOptionPane.showMessageDialog(null, "TESK Software - Winter14: " +
						"Thang Tran, Emily Linninman, Shruti More, Khanh Nguyen");
			}
		});
		JMenuItem contactItem = new JMenuItem("Contac us");
		contactItem.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		helpMenu.add(contactItem);
		contactItem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				// a pop up display email or website link.
				//suggestion email to: tesksoftware@gmail.com
				//wanna see more conference: http://www.ieee.org/index.html
				JOptionPane.showMessageDialog(null, "Email: testsoftware@gamil.com");
			}
		});
		//add(menuBar);

	}

}
